#ifndef OStruBrowser_First
#define OStruBrowser_First
#ifdef __GNUG__
#pragma interface
#endif

#include "GraphView.h"
#include "EtPeTool.h"

class MenuBar;
class Zoomer;
class Menu;

//---- PeObjectStructureView ---------------------------------------------------

class PeObjectStructureView: public GraphView {
public:
	MetaDef(PeObjectStructureView);
	PeObjectStructureView(EvtHandler*);
	~PeObjectStructureView();

	Object *GetRoot();
	VObject *NodeAsVObject(Object*);
	Iterator *MakeSubPartsIter(Object*);
	Command *NodeSelected(VObject*, int cl);

	Command *DoMenuCommand(int cmd);
	void DoSetupMenu(Menu *menu);
	void SetSelection(VObject *gp);

	//---- queries
	bool CheckObject(Object*);
	void EvtHandlers(Object*);
	void Containers(Object*);
	void Dependents(Object*);
	void References(Object*);
	void Pointers(Object*);
	void ShowObject(Object*);
	void ToggleShowLines();

	void LoadETGraph(Object *root);

private:
	void SynchSelection();

private:
	Object *currentOp, *rootOp;
	bool lines, varNames;
};

//---- ObjectBrowser -----------------------------------------------------------

class PeObjectBrowser: public EtPeTool {
public:
	MetaDef(PeObjectBrowser);
	PeObjectBrowser(Manager *m);
	~PeObjectBrowser();
	void ShowObject(Object *op);

	Point GetInitialWindowSize();
	VObject *DoMakeContent();
	MenuBar *DoMakeMenuBar();

	Command *DoMenuCommand(int cmd);
	void DoSetupMenu(Menu *mp);

	static void Spawn(Manager *m, Object *op);
	static void ShowObject(Manager *m, Object *op);

private:
	static PeObjectBrowser *objBrowser;
	PeObjectStructureView *osv;
	Zoomer *zoomer;
};

//---- PeLabeledGraphReference -------------------------------------------------

class PeLabeledGraphReference: public GraphReference {
public:
	PeLabeledGraphReference(GraphView *, Object *op, Collection *nodes,
				SeqCollection *labels, Ink *i, int width= 2, bool free= FALSE);
	~PeLabeledGraphReference();
	void DrawConnection(int n, VObject *from, VObject *to);

private:
	SeqCollection *labels;
};

//---- PeNestedIter --------------------------------------------------------------
//     iterate over a 0 terminated variable argument list of Objects
//     expanding Collections

class PeNestedIter : public Iterator {
public:
	PeNestedIter(Object *, Object *, ...);
	PeNestedIter(Collection *, bool free);
	~PeNestedIter();
	Object *operator()();
	Collection *Coll();
	void Reset();

private:
	Iterator *it, *subIter;
	Collection *cont;
	bool free;
};

#endif
